﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bridge
{
    public class StringDisplayImpl : DisplayImpl
    {
        private readonly string s;
        private readonly int width;
        public StringDisplayImpl(string s)
        {
            this.s = s;
            this.width = Encoding.UTF8.GetByteCount(s);
        }

        public override void RawClose()
        {
            this.PrintLine();
        }

        public override void RawOpen()
        {
            this.PrintLine();
        }

        public override void RawPrint()
        {
            Console.WriteLine($"|{s}|");
        }

        private void PrintLine()
        {
            Console.Write("+");
            for (var i = 0; i < width; i++)
            {
                Console.Write("-");
            }
            Console.WriteLine("+");
        }
    }
}
